/**
 * 
 */
package com.and.rsspect;

import java.io.IOException;
import java.util.List;

import org.xmlpull.v1.XmlSerializer;

/**
 * @author dai.rui.lin
 * 
 */
public abstract class AbsRSSWriter {
	private static boolean mWrap = false;

	public static final void setWrap(boolean wrap) {
		mWrap = wrap;
	}

	public static boolean isWrap() {
		return mWrap;
	}

	/**
	 * 
	 * 给XML文件添加换行符号 \n
	 * 
	 * @param xml
	 * @throws IllegalArgumentException
	 * @throws IllegalStateException
	 * @throws IOException
	 */
	public static final void writeWrap(XmlSerializer xml)
			throws IllegalArgumentException, IllegalStateException, IOException {
		if (isWrap()) {
			xml.text("\n");
		}
	}

	/**
	 * 输出并吧RSS数据写入到文件中.
	 * 
	 * @param rss
	 * @throws Exception
	 */
	abstract String writeRSS(RSS rss, String encoding,String version) throws Exception;

	/**
	 * 
	 * 写入RSS2.0元素channel数据
	 * 
	 * @param writer
	 * @param channel
	 * @throws Exception
	 */
	abstract void writeChannel(XmlSerializer writer, Channel channel)
			throws Exception;

	/**
	 * @param writer
	 * @param items
	 * @throws Exception
	 */
	abstract void writeItems(XmlSerializer writer, List<Item> items)
			throws Exception;

	/**
	 * @param writer
	 * @param author
	 * @throws Exception
	 */
	abstract void writeAuthor(XmlSerializer writer, Author author)
			throws Exception;

	/**
	 * @param categories
	 * @throws Exception
	 */
	abstract void writeCategories(XmlSerializer writer,
			List<Category> categories) throws Exception;

	/**
	 * 
	 * Allows processes to register with a cloud to be notified of updates to
	 * the channel, implementing a lightweight publish-subscribe protocol for
	 * RSS feeds. More info here.
	 * 
	 * @param cloud
	 * @throws Exception
	 */
	abstract void writeCloud(XmlSerializer writer, Cloud cloud)
			throws Exception;

	/**
	 * @param writer
	 * @param comments
	 * @throws Exception
	 */
	abstract void writeComments(XmlSerializer writer, Comments comments)
			throws Exception;

	/**
	 * 频道内容的版权说明
	 * @param writer
	 * @param copyright
	 * @throws Exception
	 */
	abstract void writeCopyright(XmlSerializer writer, Copyright copyright)
			throws Exception;

	/**
	 * 描述信息，频道描述，图片描述，一条信息的描述.
	 * @param writer
	 * @param decription
	 * @throws Exception
	 */
	abstract void writeDescription(XmlSerializer writer, Description decription)
			throws Exception;

	/**
	 * 指向该RSS文件所用格式说明的URL
	 * @param writer
	 * @param docs
	 * @throws Exception
	 */
	abstract void writeDocs(XmlSerializer writer, Docs docs) throws Exception;

	/**
	 * @param enclosure
	 * @throws Exception
	 */
	abstract void writeEnclosurce(XmlSerializer writer, Enclosure enclosure)
			throws Exception;

	/**
	 * @param extensions
	 * @throws Exception
	 */
	abstract void writeExtensions(XmlSerializer writer,
			List<Extension> extensions) throws Exception;

	/**
	 * 生成该频道的程序名
	 * @param writer
	 * @param generator
	 * @throws Exception
	 */
	abstract void writeGenerator(XmlSerializer writer, Generator generator)
			throws Exception;

	/**
	 * @param guid
	 * @throws Exception
	 */
	abstract void writeGUID(XmlSerializer writer, GUID guid) throws Exception;

	/**
	 * @param height
	 * @throws Exception
	 */
	abstract void writeHeigth(XmlSerializer writer, Height height)
			throws Exception;

	/**
	 * 指定一个 GIF或JPEG或PNG图片，用以与频道一起显示
	 * @param writer
	 * @param image
	 * @throws Exception
	 */
	abstract void writeImage(XmlSerializer writer, Image image)
			throws Exception;

	/**
	 * 
	 * 频道文章所用语言
	 * @param writer
	 * @param language
	 * @throws Exception
	 */
	abstract void writeLanguage(XmlSerializer writer, Language language)
			throws Exception;

	/**
	 * @param writer
	 * @param lastBuildDate
	 * @throws Exception
	 */
	abstract void writeLastBuildDate(XmlSerializer writer,
			LastBuildDate lastBuildDate) throws Exception;

	/**
	 * @param writer
	 * @param link
	 * @throws Exception
	 */
	abstract void writeLink(XmlSerializer writer, Link link) throws Exception;

	/**
	 * 责任编辑的email
	 * @param writer
	 * @param managingEditor
	 * @throws Exception
	 */
	abstract void writeManagerEditor(XmlSerializer writer,
			ManagingEditor managingEditor) throws Exception;

	/**
	 * @param name
	 * @throws Exception
	 */
	abstract void writeName(XmlSerializer writer, Name name) throws Exception;

	/**
	 * @param writer
	 * @param pubDate
	 * @throws Exception
	 */
	abstract void writePubDate(XmlSerializer writer, PubDate pubDate)
			throws Exception;

	/**
	 * 这个频道的分级（主要指成人、限制、儿童等）
	 * 
	 * @param rating
	 * @throws Exception
	 */
	abstract void writeRating(XmlSerializer writer, Rating rating)
			throws Exception;

	/**
	 * 提示新闻聚合器，那些天它可以跳过。
	 * 
	 * @param skipDays
	 * @throws Exception
	 */
	abstract void writeSkipDays(XmlSerializer writer, SkipDays skipDays)
			throws Exception;

	/**
	 * 提示新闻聚合器，那些小时时段它可以跳过。
	 * 
	 * @param skipHours
	 * @throws Exception
	 */
	abstract void writeSkipHours(XmlSerializer writer, SkipHours skipHours)
			throws Exception;

	/**
	 * 
	 * @param skipDays
	 * @throws Exception
	 */
	abstract void writeDays(XmlSerializer writer, List<Day> skipDays)
			throws Exception;

	/**
	 * @param skipHours
	 * @throws Exception
	 */
	abstract void writeHours(XmlSerializer writer, List<Hour> skipHours)
			throws Exception;

	/**
	 * @param source
	 * @throws Exception
	 */
	abstract void writeSource(XmlSerializer writer, Source source)
			throws Exception;

	/**
	 * 指定一个text输入框供用户输入，具体信息及功能未定。
	 * 
	 * @param textInput
	 * @throws Exception
	 */
	abstract void writeTextInput(XmlSerializer writer, TextInput textInput)
			throws Exception;

	/**
	 * @param writer
	 * @param title
	 * @throws Exception
	 */
	abstract void writeTitle(XmlSerializer writer, Title title)
			throws Exception;

	/**
	 * @param ttl
	 * @throws Exception
	 */
	abstract void writeTTL(XmlSerializer writer, TTL ttl) throws Exception;

	/**
	 * @param writer
	 * @param url
	 * @throws Exception
	 */
	abstract void writeURL(XmlSerializer writer, URL url) throws Exception;

	/**
	 * 
	 * 负责频道技术事务的网站管理员email
	 * @param writer
	 * @param webMaster
	 * @throws Exception
	 */
	abstract void writeWebMaster(XmlSerializer writer, WebMaster webMaster)
			throws Exception;

	/**
	 * @param width
	 * @throws Exception
	 */
	abstract void writeWidth(XmlSerializer writer, Width width)
			throws Exception;
}
